package bigraph.model;

import java.util.Iterator;

import org.eclipse.draw2d.geometry.Rectangle;



public class Root extends Node {

	@Override
	public Object clone() throws CloneNotSupportedException {
	     Root rt = new Root();
	     rt.setName(this.getName());
	     rt.setParent(this.getParent());
	     rt.setLayout(new Rectangle(
	                 getLayout().x + 10, getLayout().y + 10,
	                 getLayout().width, getLayout().height));
	     Iterator<Node> it = this.getChildrenArray().iterator();
	     while (it.hasNext()) {
	           Node node = it.next();
	           if (node instanceof Site) {
	                 Site child = (Site)node;
	                 Node clone = (Node)child.clone();
	                 rt.addChild(clone);
	                 clone.setLayout(child.getLayout());
	           }
	           else if (node instanceof Place) {
	                 Place child = (Place)node;
	                 Node clone = (Node)child.clone();
	                 rt.addChild(clone); 
	                 clone.setLayout(child.getLayout());
	           }
	     }
	     return rt;
	}

	
}